

function addSensorbitCod(Blockly) {





    //气体传感器模块
    Blockly.Python.microbit_gas = function (block) {
        var dropdown_gasDigital = this.getFieldValue('gasDigital');
        var dropdown_gasAnalog = this.getFieldValue('gasAnalog');
        Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
        Blockly.Python.definitions_['import_gas'] = 'from sensor import gas_detector';
        Blockly.Python.definitions_['import_gasDigital'] = 'gasDigitalPort = ' + dropdown_gasDigital;
        Blockly.Python.definitions_['import_gasAnalog'] = 'gasAnalogPort = ' + dropdown_gasAnalog;
        return '';
    }

    // // 获取气体的模拟值
    Blockly.Python.microbit_gasAnalog = function (block) {
        Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
        Blockly.Python.definitions_['import_gas'] = 'from sensor import gas_detector';
        var dropdown_gasAnalog = this.getFieldValue('gasAnalog');
        Blockly.Python.definitions_['import_gasAnalog' + dropdown_gasAnalog] = 'gasAnalogPort' + dropdown_gasAnalog + ' = ' + dropdown_gasAnalog;
        var code = "gas_detector.get_value(gasAnalogPort" + dropdown_gasAnalog + ")";
        return [code];
    }
    //  获取气体的数字值
    Blockly.Python.microbit_gasDigital = function (block) {
        Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
        Blockly.Python.definitions_['import_gas'] = 'from sensor import gas_detector';
        var dropdown_gasDigital = this.getFieldValue('gasDigital');
        Blockly.Python.definitions_['import_gasDigital' + dropdown_gasDigital] = 'gasDigitalPort' + dropdown_gasDigital + ' = ' + dropdown_gasDigital;
        var code = "gas_detector.is_detected(gasDigitalPort" + dropdown_gasDigital + ")";
        return [code];
    }

    return Blockly;
}

module.exports = addSensorbitCod;

